<template>
    <div>
        <h1>病房新增</h1>
        <table class="table">
            <tbody>
                <tr>
                    <td>病房号</td>
                    <td>
                        <input type="text" v-model="date.houseName">
                    </td>
                </tr>
                <tr>
                    <td>所属科室</td>
                    <td>
                        <select v-model="date.kHouseId">
                            <option value="0">请选择</option>
                            <option v-for="a in data" :value="a.kHouseId">{{ a.kHouseName }}</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>床位总数量</td>
                    <td>
                        <input type="text" v-model="date.zNun">
                    </td>
                </tr>
                <tr>
                    <td>状态</td>
                    <td>
                        <input type="checkbox" v-model="date.state">勾选为启用,否则未满
                    </td>
                </tr>
                <tr>
                    <td>空闲床数量</td>
                    <td>
                        <input type="text" v-model="date.kNum">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td colspan="2">
                        <input type="button" value="新增" @click="add">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,onMounted } from 'vue';
import { useRouter } from 'vue-router';
const routher = useRouter()
onMounted(()=>{
    getdate()
})
const add=()=>{
    axios.post("/api/House/AddHouse",date.value).then(res=>{
        if(res.data>0){
            alert("新增成功")
            routher.push({path:"/Showh"})
        }
        else{
            alert("新增失败")
        }
    })
}
const date=ref({
  "houseId": 0,
  "houseName": "",
  "kHouseId": 0,
  "zNun": 0,
  "state": false,
  "kNum": 0,
  //"createTimes": ""
})
const getdate=()=>{
    axios.get("/api/KHouse/Xia").then(res=>{
        data.value=res.data
    })
}
const data=ref([{
    "kHouseId": 0,
    "kHouseName": ""
}])
</script>

<style scoped>

</style>